<?php

    namespace Product\Controller;

    use Common\Controller\AdminbaseController;

    class AdminComplaintcontroller extends AdminbaseController {
        protected $m_complaint;

        function _initialize() {
            parent::_initialize();
            $this->m_complaint = M("Complaint");
        }

        /**
         * 留言列表
         */
        public function index(){

            $s_tid = I("post.s_tid");
            $keyword = I("post.keyword");
            $this->assign("s_tid",$s_tid);
            $where = array();
            if(!empty($s_tid)){
                $where['type'] = $s_tid;
            }
            if(!empty($keyword)){
                $where['content'] = array('like',"%$keyword%");
            }

            $count=$this->m_complaint->count();
            $page = $this->page($count, 15);
            $list = $this->m_complaint->field("c.*,u.user_nicename")->alias("c")
                ->where($where)
                ->join("lz_users u ON u.id = c.userid")
                ->order("create_time desc")
                ->limit($page->firstRow , $page->listRows)
                ->select();
            $this->assign("page", $page->show('Admin'));
            $this->assign("list",$list);
            $this->display();
        }


    }